#!/usr/bin/env python
# -*- coding: utf8 -*-

## importing my src modules and files
from sys import path as spath
from os import path as opath
spath.append(opath.abspath("src"))

from ui import ui
import ConfigParser

if __name__ == "__main__":
    ##loading configuration
    if opath.exists("ericbeta.ini"):
        config_file = ConfigParser.ConfigParser()
        config_file.read("ericbeta.ini")
        config = {}
        
        for sec in config_file.sections():
            name = sec.lower()
            for opt in config_file.options(sec):
                config[name + "." + opt.lower()] = config_file.get(sec, opt).strip()
        if config["connection.gammu"] == "":
            config["connection.gammu"] = "-1"
    else:
        config = {"connection.serial": "", "connection.gammu":"-1"}
    print config
    app = ui(dir = "src/", init_gammuCS = int(config["connection.gammu"]), init_serialP = config["connection.serial"])
    app.main()